package com.wmzdq.photocenter.common;

import java.io.File;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.wmzdq.photocenter.bean.FileBean;
import com.wmzdq.photocenter.bean.MenuBean;
import com.wmzdq.photocenter.file.IFileOperator;

@Component
public class CoverMenu {

	@Autowired
	IFileOperator operator;
	
	@Autowired
	PropertyUtil proUtil;
	
	public MenuBean cover(String name){
		MenuBean bean=new MenuBean();
		bean.setName(name);
//		
//		String current=operator.getCurrent();
//		if(StringUtils.isNotBlank(current)){
//			current+=File.separator+name;
//		}else{
//			current=name;
//		}
		//bean.setUrl("/directory/getFiles?path="+name);
		//bean.setUrl("#/photo");
		bean.setPath(proUtil.get(name));
		
		return bean;
	}
	
	public FileBean coverFile(String name,int index,String thum,String path,String video){
		FileBean bean=new FileBean();
		bean.setName(name);
		
		
		bean.setUrl("/file/"+path+File.separator+name);
		bean.setIndex(""+index);
		bean.setThumpath("/file/"+thum);
		if(StringUtils.isNotEmpty(video)){
			bean.setFlag(FileTypeConstant.LIVEPHOTO);
			bean.setVideoUrl("/file/"+path+File.separator+video);
		}else{
			bean.setFlag(FileTypeConstant.PHOTO);
		}
		
		
		return bean;
	}
}
